home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / pavt150.zip / AVTSPECS.ZIP / AVATAR.DOC next >
Text File  |  1990-09-10  |  46KB  |  885 lines

  1.                 AVATAR Console, Level 1, Specification
  2.  
  3.                 Copyright (C) 1990, G. Adam Stanislav
  4.                 All Rights Reserved
  5.  
  6. 1. This document assumes you are familiar with Avatar 0 and Avatar 0+
  7. (AVT/0 and AVT/0+) specifications.
  8.  
  9. 2. Avatar, level 1 (AVT/1), consists of two main divisions:
  10.  
  11.         - Avatar protocol
  12.         - Avatar console
  13.  
  14. 3. Avatar protocol is designed for more efficient use of online services.
  15. It will be described in a separate document. For now, let us just reveal
  16. that Avatar protocol is based on an asymetrical model. In this it differs
  17. from many protocols, especially those used for file transfer.
  18.  
  19. 4. Symetrical protocols are designed as if both ends of the communications
  20. link were equal. Most file transfer protocols, such as Xmodem, are symetrical.
  21. They do not distinguish between the uplink and the downlink. A file can be
  22. both downloaded and uploaded using the same Xmodem protocol.
  23.  
  24. 5. In real life, computers are not designed symetrically. There is the CPU and
  25. the console, or the system and the terminal, or the BBS and the user, etc.
  26. Symetrical protocols can ignore this distinction because of their limited
  27. purpose.
  28.  
  29. 6. Avatar, as an asymetrical protocol, allows more than file transfer. It can
  30. handle such things as a user logon to a system, transfer of multiple files
  31. in either direction simultaneously with other activities, etc. Further
  32. details are beyond the scope of this document.
  33.  
  34. 7. Avatar console is the division of Avatar that most of us are already
  35. familiar with. Level 0 is used by Opus-CBCS, version 1.10 and up. While
  36. Avatar protocol is designed to work with serial communications, Avatar
  37. console can also be used locally. It can be implemented either in hardware
  38. or software. The enclosed AVATAR.SYS is an example of Avatar console
  39. software implementation in MS DOS world. We will be calling AVATAR.SYS, or
  40. any similar software, as well as any appropriate hardware circuits "the
  41. driver."
  42.  
  43. 8. There were three main reasons for the development of Avatar console:
  44.  
  45.         - speed
  46.         - versatility
  47.         - portability
  48.  
  49. 9. A similar system has been in use, often called "ANSI graphics." This
  50. designation is only partly correct. It does not deal with graphics. It is
  51. character oriented (just as AVT/1 is). It is only a subset of ANSI standard.
  52.  
  53. 10. ANSI graphics lack in all three main reasons for Avatar console as listed
  54. above. It uses long codes which are easy for humans to read. However, as they
  55. control the console, they are never read anyway. But an ANSI code to set
  56. color attribute can be up to 7 bytes long. A comparable Avatar code is three
  57. bytes long, thus takes much less time to transfer over the communication
  58. link.
  59.  
  60. 11. ANSI graphics were designed a while ago and do not support many modern
  61. ideas, such as multiple windows, sound control, direction of the flow, etc.
  62. Avatar console incorporates these commands.
  63.  
  64. 12. There are many dialects of ANSI graphics. While there is a defined
  65. standard, various manufacturers decided to adapt whatever they wanted. Avatar
  66. console is very straightforward. Because it was not defined by a committee,
  67. there are no compromises in Avatar console.
  68.  
  69.         Avatar, level 1 (AVT/1), console control codes:
  70.  
  71.         Overview:
  72.  
  73. 13. Except for ^L (clear current window) and ^Y (repeat character), all Avatar
  74. control codes start with AVTCODE (^V, SYN, 22 decimal, 16 hexadecimal).
  75. AVTCODE is followed by a one-byte code defining the command. The command
  76. byte may be followed by parameters. While the number of parameters varies
  77. from command to command, it is always the same for the same command. The only
  78. exception is ^V^Y - repeat pattern.
  79.  
  80. 14. There is a clue to know whether an Avatar code is a console code or a
  81. protocol code. Avatar console commands are in the range of 01-3F hexadecimal.
  82. Avatar protocol codes are above this range. There is no Avatar control code
  83. of 00. If a control code greater than 3F is somehow sent to the console, the
  84. driver turns its high bits off like this:
  85.  
  86.                 code = code AND 3F;
  87.  
  88. 15. This overview lists the console command codes without the initial AVTCODE
  89. or parameters. The command code is followed by the number of parameters the
  90. code uses, then by a brief desription.
  91.  
  92.         ^A  - 1 - set current attribute
  93.         ^B  - 0 - turn blink on
  94.         ^C  - 0 - move cursor one line up
  95.         ^D  - 0 - move cursor one line down
  96.         ^E  - 0 - move cursor one column left
  97.         ^F  - 0 - move cursor one column rught
  98.         ^G  - 0 - clear to the end of the line
  99.         ^H  - 2 - locate cursor position
  100.         ^I  - 0 - turn insert mode on
  101.         ^J  - 5 - scroll area up
  102.         ^K  - 5 - scroll area down
  103.         ^L  - 3 - clear area, set current attribute
  104.         ^M  - 4 - initialize area, set current attribute
  105.         ^N  - 0 - delete character, sroll eol left
  106.         ^O  - 0 - turn clockwise mode on
  107.         ^P  - ? - dummy call, NOP
  108.         ^Q  - 1 - query the driver
  109.         ^R  - 0 - reset the driver
  110.         ^S  - 3 - sound a tone
  111.         ^T  - 1 - highlight cursor position
  112.         ^U  - 2 - highlight a window
  113.         ^V  - 6 - define a window
  114.         ^W  - 1 - switch to a window
  115.         ^X  - 0 - flush input
  116.         ^Y  - * - repeat pattern
  117.         ^Z  - ? - <reserved>
  118.         ESC - ? - reserved for ANSI
  119.         FS  - 0 - go to sleep
  120.         GS  - 0 - wake up
  121.         RS  - 0 - start vertical mode
  122.         US  - 0 - end vertical mode
  123.         SP  - ? - <reserved>
  124.         !   - 4 - poke
  125.         "   - 0 - do not wrap at eol (wrap off)
  126.         #   - 0 - switch direction at eol (wrap zigzag)
  127.         $   - 0 - wrap at eol (wrap on)
  128.         %   - 0 - reverse LF action
  129.         &   - 0 - normalize LF action
  130.         '   - 1 - set cursor type
  131.         (   - 0 - do not print in reverse
  132.         )   - 0 - print in reverse
  133.         *   - 1 - make system pause
  134.         +   - 0 - insert line
  135.         ,   - 0 - insert column
  136.         -   - 0 - delete line
  137.         .   - 0 - delete column
  138.         /   - 1 - set/reset static mode
  139.         0   - 1 - highlight eol
  140.         1   - 1 - highlight bol
  141.         2-9 - ? - <reserved>
  142.         :   - 1 - keyboard mode
  143.         ;   - ? - <reserved>
  144.         <   - 5 - scroll area left
  145.         =   - 1 - set parser mode (cooked or raw)
  146.         >   - 5 - scroll area right
  147.         ?   - 2 - peek
  148.  
  149.         Detailed description:
  150.  
  151.         ^L         - Clear the current window and set current attribute
  152.                    to default. Change current attribute to equal default
  153.                    attribute. In AVT/0 the default attribute is always 3.
  154.                    In AVT/1, the default attribute of window 0 is 7. All
  155.                    other windows can have any default attribute defined.
  156.  
  157.         ^Y <a> <b> - Print byte <a> <b> times.
  158.  
  159.         ^V ^A <a>  - Set current color attribute to <a>. Default attribute
  160.                    remains unchanged. If <a> has high bit set, ignore it.
  161.  
  162.         ^V ^B      - Turn blink on.
  163.  
  164.         ^V ^C      - Move the cursor one line up. Do nothing if you are
  165.                    at the top line of current window already.
  166.  
  167.         ^V ^D      - Move the cursor one line down. Do nothing if you are
  168.                    at the bottom line of current window already.
  169.  
  170.         ^V ^E      - Move the cursor one column to the left. Do nothing
  171.                    if you already are at the leftmost column of the window.
  172.  
  173.         ^V ^F      - Move the cursor one column to the right. Do nothing
  174.                    if you already are at the rightmost column of the window.
  175.  
  176.         ^V ^G      - Clear the rest of line (cleol) in current window
  177.                    using current attribute.
  178.  
  179.         ^V ^H <r> <c> - Move the cursor to row <r> and column <c> in current
  180.                    window. Note that the upper left corner of the window
  181.                    is 1, 1.
  182.  
  183. 16. All of the above codes have been defined in the original AVT/0 spec. They
  184. function identically as before, however, they do not necessarily control
  185. the entire screen. AVT/0 recognized only 1 window which covered the entire
  186. screen and had a default attribute of 3. AVT/1 recognizes 256 windows,
  187. numbered 0-255. They originally cover the entire screen and have a default
  188. color attribute of 7. In window 0 these defaults cannot be changed, in all
  189. other windows they can as described later.
  190.  
  191. 17. To emulate AVT/0 with an AVT/1 driver, define a window (other than 0), make
  192. it cover the entire screen and set its default attribute to 3. Set the parser
  193. mode to raw (see later for details). Switch to that window. Now you are
  194. fully compatible with AVT/0.
  195.  
  196.         ^V ^I      - Turn insert mode ON. It stays on until any other
  197.                    Avatar console command except ^Y and ^V ^Y. Switching
  198.                    to a different window and then back does not turn it
  199.                    off either (although it is confined to the window it
  200.                    was defined in).
  201.  
  202.         ^V ^J <a> <b> <c> <d> <e> - Scroll area <bcde> up by <a> lines.
  203.                    If <a> is 0 or greater than the number of lines in the
  204.                    window, this command will clear the area. Whatever is
  205.                    scrolled in, is set to current attribute. (This can be
  206.                    used as an alternative to clearing the screen without
  207.                    changing current attribute, although better alternatives
  208.                    exist).
  209.  
  210.         ^V ^K <a> <b> <c> <d> <e> - Same as ^V ^J but scroll the are down.
  211.  
  212.         ^V ^L <a> <b> <c> - Clear area, starting at current cursor position,
  213.                    of <b> lines and <c> columns, using <a> color attribute.
  214.                    <a> also becomes the new current attribute.
  215.                    This is probably the most efficient way of clearing an
  216.                    area of the screen without forcing the current attribute
  217.                    to be the same as default attribute. It is a subcommand
  218.                    of ^V ^M with its character parameter defaulting to blank.
  219.  
  220.         ^V ^M <a> <b> <c> <d> - Initialize area. Similar to ^V ^L. It sets
  221.                    current attribute to <a> and fills <c> lines and <d>
  222.                    columns with character <b>.
  223.  
  224.         ^V ^N      - delete character at current cursor position. Scroll the
  225.                    rest of the line in current window left.
  226.  
  227.         ^V ^Y <a> [...] <c> - repeat pattern. <a> defines the number of bytes
  228.                    in the pattern, <c> the number of times the pattern
  229.                    should be repeated. If either value is a zero, nothing
  230.                    is done. The pattern can contain Avatar console codes,
  231.                    including other ^V ^Y patterns.
  232.  
  233. 18. The above commands were defined in AVT/0+. There is one change from AVT/0+
  234. int AVT/1: A backspace moves one column back (unless at the leftmode end of
  235. the window already). In AVT/0 this did not overwrite the character at that
  236. position. This behavior was not using backspace in its usual manner and
  237. was unnecessarily duplicating another AVT/0 command. Therefore, AVT/1 console
  238. will print a blank in current attribute over the character the cursor is
  239. moved to. This corresponds to the way backspace is generally used in other
  240. console systems. It does not really break backwards compatibility because
  241. Opus 1.10+ always sends a BS SP BS sequence which results in the same. I am
  242. not sure at the moment what Luke does, but since Luke was not released yet,
  243. I will fix it to work as defined here. I am not aware of any other BBS
  244. software using Avatar, everyone seems to have been waiting for this doc. :-)
  245.  
  246. 19. New commands in AVT/1:
  247.  
  248.         ^V ^O      - turn clockwise mode on. If the cursor is not at the
  249.                    edges of the window, printing continues in the same
  250.                    direction as it was before this command was issued.
  251.                    However, once an edge is reached (typically the rightmost
  252.                    column of the window), printing continues in clockwise
  253.                    direction. That means: If at the rightmost column, text
  254.                    is printed downwards; if in the last row, text is printed
  255.                    to the left; in the leftmost column text is moving upwards;
  256.                    in the first row it is printed to the right.
  257.  
  258.                    This command is designed to allow creating a frame
  259.                    around a window. Typically, the window should be shrunk
  260.                    by one column and row in every direction after the
  261.                    frame was created. Otherwise the frame will be overwritten.
  262.  
  263.                    The frame mode stays on until a CR is sent to the console.
  264.  
  265.         ^V ^P      - This is a dummy call. ^P is the same as DLE which
  266.                    could become real confusing.
  267.  
  268.         ^V ^Q <a>  - Query the driver. <a> defines the type of query. The
  269.                    driver sends its reply to stdout (or to the serial port
  270.                    if the driver is designed to work in serial communications
  271.                    only). This can be used to determine whether an AVT/1
  272.                    console driver is present. If no reply is detected, AVT/0
  273.                    or no Avatar at all should be assumed.
  274.  
  275.                    If stdout is buffered, the reply is given highest
  276.                    possible priority. In other words, sending a query to
  277.                    stdout will result in the reply being the next thing
  278.                    read from stdin, even if something else was waiting in
  279.                    stdin buffer. However, if several queries are send to
  280.                    Avatar console, the replies will come out in the same
  281.                    order as the queries.
  282.  
  283.                    In practical life this means stdin has two buffers,
  284.                    on for regular input, one for replies to Avatar queries.
  285.                    The replies to queries are appended to reply buffer.
  286.                    But stdin always checks the reply buffer before its
  287.                    regular buffer.
  288.  
  289.                    It is important to realize that the size of reply
  290.                    buffer is only guaranteed to hold the longest reply
  291.                    possible. If several queries occur in a row without
  292.                    reading the replies, the reply buffer may overflow.
  293.                    In that case, no new replies will be appended until
  294.                    some room is cleared in the reply buffer.
  295.  
  296.                    This means a query should be immediately followed by
  297.                    reading the reply. However, you may want to place several
  298.                    queries which result in short replies (see below)
  299.                    when using AVT/1 in serial communications because of
  300.                    the propagation delay.
  301.  
  302.                    Individual queries and types of replies that offer
  303.                    are described later in this document.
  304.  
  305.         ^V ^R      - reset the driver. All windows are reset to the
  306.                    initial default values: full screen, color attribute
  307.                    7, left-to-write, regular cursor, etc. Window 0 becomes
  308.                    current default window. Cursor position remains at the
  309.                    same physical position on the screen it was immediately
  310.                    before the reset.
  311.  
  312.                    A remote system should never issue the reset command.
  313.                    Instead, it should send ^V followed by capital R. This
  314.                    is the Avatar protocol Reset Request. We are running ahead
  315.                    of ourselves by saying this, but Avatar console is designed
  316.                    to work with Avatar protocol (at least for remote control).
  317.                    Originally, we did not intend to release Avatar console
  318.                    specs before Avatar protocol specs but too many people
  319.                    have asked we do...
  320.  
  321.                    At any rate, the reason why a remote system should not
  322.                    release the reset command directly is that it lets the
  323.                    local terminal program decide whether it should be using
  324.                    raw or cooked mode for the output. The reset command
  325.                    places Avatar console in cooked mode. As will be
  326.                    explained in the protocol specs, the local terminal may
  327.                    not want to use the cooked mode. Thus, an intelligent
  328.                    Avatar terminal *may* decide to switch back to raw mode
  329.                    after it issues the reset command.
  330.  
  331.                    This in no way interferes with terminal programs that are
  332.                    not AVT/1 aware and that simply send output to AVATAR.SYS
  333.                    without even knowing about it. If you re-read paragraph
  334.                    14 above, you will notice that the parser will convert
  335.                    the R to a ^R before sending it out to the interpreter.
  336.                    Please note it must be a CAPITAL R for this to function
  337.                    properly.
  338.  
  339.         ^V ^S <a> <b> <c> - Sound tone <a> in octave <b> of duration <c>.
  340.                    The tone byte is defined by the following formula:
  341.  
  342.                        <a> = (tone - 'A') * 2 + sharp
  343.  
  344.                    In this formula, tone is somewhere between 'A' and 'G',
  345.                    sharp = 0 or 1 as case may be.
  346.  
  347.                    In other words, A = 0, A# = 1, B = 2, B# = 3, etc.
  348.                    If the value of <a> is 14 or greater, a musical pause
  349.                    of duration <c> is included. In that case the octave
  350.                    parameter is ignored and can have any value.
  351.  
  352.                    Please note that some tones are musically identical.
  353.                    Thus E# is the same as F. Avatar lets you request
  354.                    either but will of course make identical sounds for
  355.                    the two.
  356.  
  357.                    Musically, B# is the same as C. Because, however,
  358.                    an octave starts with a C and ends with a B#, Avatar
  359.                    will not play the same tone for B# and C. B# sharp
  360.                    will be one octave above C.
  361.  
  362.                    Octave is a signed integer (8 bits). Middle octave
  363.                    equals 0, next higher equals 1, etc. The octave
  364.                    below middle equals -1 (same as 255 unsigned), etc.
  365.                    Please be advised there are only so many octaves human
  366.                    ear can detect.
  367.  
  368.                    Duration is defined in tenths of a second (depending
  369.                    on the computer system this value is approximate,
  370.                    AVATAR.SYS uses two clock ticks as its measure, i.e.
  371.                    1/9.1 sec). If two identical tones follow each other
  372.                    with no intervening pause, Avatar will play them legato,
  373.                    without a break.
  374.  
  375.                    Avatar console buffers the tones requested. The size
  376.                    of the buffer may vary from driver to driver, but as
  377.                    long as the system has the ability of at least primitive
  378.                    multitasking, processing continues while music plays.
  379.                    This is of course the case with AVATAR.SYS as multitasking
  380.                    is fairly easy to achieve on the PC.   :-)
  381.  
  382.         ^V ^T <a>  - highlight current cursor position. Color attribute
  383.                    at current cursor position is replaced with <a>. If the
  384.                    high bit of <a> is on, the highlighted character will
  385.                    start blinking. This command does not change current
  386.                    attribute or default attribute, only highlights the one
  387.                    character at cursor position.
  388.  
  389.         ^V ^U <a> <b> - highlight window <a> with the attribute of <b>.
  390.                    The entire window is filled with attribute <b>. Any
  391.                    characters present in the window will remain there,
  392.                    only their color attribute will change. The command
  393.                    does not change current or default attribute. This
  394.                    command was designed with menus in mind, but of
  395.                    course can be used for other purposes.
  396.  
  397.         ^V ^V <a> <b> <c> <d> <e> <f> - define a window. Window, in
  398.                    Avatar terminology, is an area of the screen with
  399.                    certain attributes (such as color, direction of the
  400.                    flow, wrap behavior, etc.). Every window has a handle,
  401.                    which is a byte between 0-255. That means there are
  402.                    256 windows altogether. Initially, all windows have
  403.                    the same size (full screen) and attributes (color 7,
  404.                    left-to-right direction, wrap on, etc.). This command
  405.                    redefines window <a> to color attribute <b> and
  406.                    location <cdef> on the physical screen. It does not
  407.                    switch to the window, only defines it. However, if that
  408.                    happens to be the default window, changes happen
  409.                    immediately. If this means that the cursor ends up
  410.                    outside of the redefined window, it is moved to the
  411.                    closest position inside. If, on the other hand, the
  412.                    cursor is inside the window after its parameters
  413.                    changed, the cursor remains at the same physical location
  414.                    it was before.
  415.  
  416.                    The color attribute <b> sets both the default attribute
  417.                    and current attribute. Default attribute can be changed
  418.                    only with this command, while current attribute can be
  419.                    changed with commands, already described above.
  420.  
  421.                    Window 0 is special in that it covers full screen and
  422.                    has default color attribute of 7. This window cannot
  423.                    be redefined. Any attempt to redefine window 0 will be
  424.                    ignored: Avatar driver will read the command but not
  425.                    act on it.
  426.  
  427.                    Note that AVT/0 only has one window which covers the full
  428.                    screen and has default attribute of 3. The simplest
  429.                    way to emulate AVT/0 is by defining a full screen window
  430.                    with color attribute 3 and switching to it. Obviously,
  431.                    it has to be a window other than 0.
  432.  
  433.         ^V ^W <a>  - switch to the window whose handle is <a>. All screen
  434.                    output will be confined to the area of the window in
  435.                    the attributes of the window. Avatar driver remembers
  436.                    all the attributes of every window and restore them
  437.                    each time you switch to a window. This includes color
  438.                    attributes, cursor position, cursor type, direction
  439.                    of the flow, wrap mode, etc.
  440.  
  441.                    Rapidly switching among windows and writing to them
  442.                    will create the illusion of simultaneous writing to
  443.                    several windows.
  444.  
  445.                    Unlike the attributes, the *contents* of a window are
  446.                    not preserved when a window switch occurs. That means
  447.                    that overlapping windows overwrite each other. This is
  448.                    why it is important to understand Avatar windows as
  449.                    areas of the screen with certain attributes and nothing
  450.                    else. It is the responsibility of the application
  451.                    to save and restore contents of windows if it wants
  452.                    to have overlapping windows that do not destroy each
  453.                    others contents. The peek and poke commands described
  454.                    below make this possible.
  455.  
  456.         ^V FS      - put the interpreter to sleep. The parser remains
  457.                    active (the difference between the interpreter and the
  458.                    the parser is described elsewhere in this document),
  459.                    and will still process any queries. Other than that,
  460.                    it will pass all output to the console that existed
  461.                    before Avatar console.
  462.  
  463.                    This command was added to accommodate systems that
  464.                    need both AVATAR and ANSI consoles. Because there is
  465.                    no provision in ANSI console for any "competition,"
  466.                    Avatar lets you pretend it is not there.
  467.  
  468.                    In practical life on a PC, if you load ANSI.SYS
  469.                    *before* AVATAR.SYS, you can switch between them
  470.                    by issuing this and the following command.
  471.  
  472.                    By the way, FS is ASCII 28, or 1C hex.
  473.  
  474.         ^V GS      - complement of previous command. It will wake Avatar
  475.                    interpreter up. All commands will be processed by
  476.                    Avatar console.
  477.  
  478.                    GS is ASCII 29, 1D hex.
  479.  
  480.         ^V RS      - switch current window to vertical mode. In other
  481.                    words, from now on write vertically rather than
  482.                    horizontally. This command was added to accomodate
  483.                    languages such as Japanese that write vertically.
  484.                    (RS is ASCII 30, or 1E hex.)
  485.  
  486.         ^V US      - switch to horizontal mode. It complements previous
  487.                    command. US is ASCII 31, 1F hex. It is also a country
  488.                    that usually writes horizontally.
  489.  
  490.         ^V ! <a> <b> <c> <d> - poke character <a> of color attribute <b>
  491.                    at the <cd> location of the *physical* screen. This is
  492.                    a low level command which bypasses the window structure.
  493.                    Or, if you prefer, you can say it always writes to
  494.                    window 0, no matter what the current window is.
  495.  
  496.                    It does not change anything else: Further processing
  497.                    continues in the same window at the same cursor
  498.                    position as before. If you are a programmer, you can
  499.                    think of it as an "interrupt."
  500.  
  501.         ^V "       - turn wrap off in current window. In other words, if
  502.                    you come to the window boundary, ignore all output until
  503.                    you get to a carriage return (although a line feed should
  504.                    still work).
  505.  
  506.         ^V #       - wrap in zigzag mode. Whenever you come to the window
  507.                    boundary, *or* encounter a carriage return, reverse the
  508.                    direction of the flow.
  509.  
  510.                    In other words, zigzag between left-to-right and
  511.                    right-to-left, or between top-to-bottom and
  512.                    bottom-to-top.
  513.  
  514.                    This was added because some languages write this
  515.                    way.
  516.  
  517.         ^V $       - wrap at end of line without switching the direction
  518.                    of the flow. This is the default after a reset.
  519.  
  520.         ^V %       - reverse LF action. Normally, line feed moves the
  521.                    cursor to next line (or column in vertical mode).
  522.                    This command tells Avatar to move the cursor to
  523.                    previous line (column).
  524.  
  525.         ^V &       - normalize LF action. It cancels out previous command.
  526.                    LF will cause the cursor to move to next line (column).
  527.  
  528.         ^V ' <a>   - set cursor type. The value of <a> decides the type:
  529.                         1 - default,
  530.                         2 - hidden,
  531.                         3 - big.
  532.  
  533.                    In the above, 1, 2 and 3 are binary number, i.e.,
  534.                    you can call them ^A, ^B and ^C if you prefer.
  535.  
  536.                    Default cursor type is the regular cursor the computer
  537.                    uses most of the time. Hidden cursor is invisible.
  538.                    Big cursor covers the entire character cell.
  539.  
  540.         ^V (       - do not print in reverse. This is the default. It
  541.                    cancels out next command and cause Avatar to print
  542.                    left-to-right in horizontal mode or top-to-bottom
  543.                    in vertical.
  544.  
  545.         ^V )       - print in reverse. This is here to accommodate Hebrew
  546.                    and other languages that print right-to-left. In vertical
  547.                    mode it prints bottom-to-top.
  548.  
  549.         ^V * <a>   - system pause. The length of the pause is defined
  550.                    by <a>. Its value is in tenths of a second. If <a>
  551.                    equals 0, the system will pause for an hour.
  552.  
  553.                    There is a potential of abuse here. A jokester could
  554.                    transfer a ^V ^Y ^C ^V * ^@ <255> and lock up the
  555.                    system for ten days and 15 hours.Therefore,
  556.                    AVATAR.SYS lets you break out of the pause command
  557.                    by pressing the SysRq key. In case of a loop like the
  558.                    one described above you may need to press the key several
  559.                    times. AVATAR.SYS clears its pause flag both when SysRq
  560.                    is depressed and released.
  561.  
  562.         ^V +       - insert a blank line at current cursor position.
  563.                    In vertical mode it inserts a column.
  564.  
  565.         ^V ,       - insert a blank column. In vertical mode it inserts
  566.                    a blank line.
  567.  
  568.         ^V -       - delete current line. In vertical mode it deletes
  569.                    current column.
  570.  
  571.         ^V .       - delete current column (line in vertical mode).
  572.  
  573.         ^V / <a>   - set or reset static mode depending on the value of
  574.                    <a>. If <a> = '[', start (set) static mode. If <a> = ']',
  575.                    end (reset) static mode. Any other version of <a> does
  576.                    nothing.
  577.  
  578.                    In static mode, cursor is not advanced to the next position
  579.                    after a character has been written. With insert mode OFF,
  580.                    this will mean that every character overwrites the previous
  581.                    character written. With insert mode ON, this will create
  582.                    some interesting special effects.
  583.  
  584.         ^V 0 <a>   - highlight eol. Current cursor position and the
  585.                    rest of the line will change their color attributes
  586.                    to <a>. Current and default color attributes are
  587.                    unaffected.
  588.  
  589.         ^V 1 <a>   - highlight bol. Current cursor position and all the
  590.                    characters before it all the way to the beginning
  591.                    of the line are highlighted.
  592.  
  593.                    The above six commands were designed mostly with
  594.                    full screen editors in mind.
  595.  
  596.         ^V : <a>   - keyboard mode. By default, the input from Avatar console
  597.                    comes in the form of ASCII codes for whatever character
  598.                    is typed. If a function key is pressed, Avatar console
  599.                    inputs a NUL (ASCII 0) followed by the keyboard scan code.
  600.                    On a non-IBM system this scan code is expected to be the
  601.                    scan code of the comparable key of the IBM PC keyboard.
  602.                    This is known as PC keyboard emulation, and has been
  603.                    documented since AVT/0.
  604.  
  605.                    OPTIONALLY, it is possible to change this behavior with
  606.                    this command. <a> is a numeral between 0 and 4. By numeral
  607.                    we mean a character '0' rather than binary 0. In other
  608.                    words numerals 0-4 are ASCII codes 30-34 hexadecimal.
  609.  
  610.                    This command clears the keyboard buffers (both the system
  611.                    buffer and the Avatar driver internal buffer). If
  612.                    applicable, it changes the input behavior. It then returns
  613.                    itself with the new value of input behavior. Behavior 0
  614.                    is the default and must be supported by any Avatar driver
  615.                    to be compatible. The rest of them are optional.
  616.  
  617.                    If an invalid or unsupported <a> is used in this command,
  618.                    Avatar console clears the buffers, then returns this command
  619.                    with the current behavior.
  620.  
  621.                    As this command is more complex than most others, it is
  622.                    described below in more detail.
  623.  
  624.         ^V < <a> <b> <c> <d> <e> - scroll area left. Works just like
  625.                    ^V ^J but left.
  626.  
  627.         ^V = <a>   - set parser mode. If <a> equals 'R', the mode is set
  628.                    to raw. If it equals 'C', the mode is set to cooked.
  629.  
  630.                    Avatar console ands <a> with 1Fh before evaluating it.
  631.                    Then it compares it ^R and ^C. That means the value can
  632.                    be 'R', 'r', ^R, 'C', 'c', ^C, and even some others
  633.                    that result in ^R or ^C with their hight bits turned off.
  634.  
  635.         ^V > <a> <b> <c> <d> <e> - scroll area right. Same as ^V ^J but
  636.                    scrolls right.
  637.  
  638.         ^V ? <a> <b> - peek at the physical location <ab> on the screen.
  639.                    It returns appropriate poke command in reply buffer.
  640.                    In other words, it writes a poke into stdout. Similar to
  641.                    poke, it bypasses the window structure and works on
  642.                    the physical screen.
  643.  
  644.                    The peek and poke commands allow for limited pop-up
  645.                    windows sent over serial lines. The program simply
  646.                    peeks at every screen position it wants to overwrite,
  647.                    and pokes the new value in it. It stores the result
  648.                    of the peeks in a buffer. When it wants to restore
  649.                    the original window, it simply sends the buffer out.
  650.  
  651.                    Granted, this will work slow in a large window at
  652.                    300 baud, but it is pretty much the only way to do it.
  653.  
  654.                    For *local* console only, commercial version of
  655.                    AVATAR.SYS contains functionality to achieve the
  656.                    same result instantly, bypassing Avatar codes. But
  657.                    that cannot work remotely.
  658.  
  659.                    Avatar protocole (not console) will have provisions
  660.                    for achieving the same result more efficiently. But
  661.                    that requires the collaboration of the terminal
  662.                    program. It cannot be achieved by the console driver
  663.                    alone without reserving megabytes of memory for its
  664.                    use.   :-)
  665.  
  666.         The two steps of Avatar console processing
  667.  
  668. 20. Avatar console works in two steps:
  669.  
  670.                    1. parsing
  671.                    2. interpreting
  672.  
  673. 21. As a matter of fact, just about every console uses these two steps,
  674. although they may not necessarily talk about it. Because of these two steps,
  675. Avatar console driver consists of two distinct sections:
  676.  
  677.                    1. the parser, and
  678.                    2. the interpreter
  679.  
  680. 22. Again, this is nothing new to the student of computer science, although it
  681. may be new, even confusing, to the casual computer user.
  682.  
  683. 23. When a character is sent to Avatar console for output through stdout, it
  684. first goes to the parser. Depending on the current setup defined by the parser
  685. control codes as well as some other circumstances, the parser will or will not
  686. modify the character before sending it out.
  687.  
  688. 24. Secondly, depending on the current setup, the parser will send the
  689. character out to the interpreter, or it will send it out to the parser of
  690. another console such as ANSI or TTY.
  691.  
  692. 25. That said, let us discuss the first idea, that of changing or not changing
  693. the character. To my great surprise there seems to have been some confusion
  694. about how AVT/0 parser was supposed to be behaving at this point. To see why,
  695. let's get into some historical perspective:
  696.  
  697.                    Avatar console was not developed from scratch. Rather,
  698.                    it descended from a creature of Wynn Wagner, III, called
  699.                    oANSI. Wynn, the original author of Opus-CBCS, wanted to
  700.                    simplify screen handling as far as the Opus sysop was
  701.                    concerned. At that time, ANSI escape sequences were just
  702.                    about the only way of controlling the remote screen.
  703.  
  704.                    Wynn developed a system of codes which were much shorter
  705.                    than ANSI. These are the same codes used in the original
  706.                    AVT/0 spec. They were designed specifically for Opus, which
  707.                    explains some of the quirks of AVT/0 (such as default
  708.                    color attribute of 3 rather than 7). Opus is able to read
  709.                    a file containing these sequences and convert them to the
  710.                    appropriate ANSI sequences.
  711.  
  712.                    At the time Opus first came out, however, oANSI codes were
  713.                    just pure binary codes. If you wanted to use them, you had
  714.                    to type them in by hand using your favorite editor.
  715.                    Because oANSI can contain any control code imaginable,
  716.                    and because different text editors are using different
  717.                    control codes as their own editing commands, there was a
  718.                    need to bypass the limitation.
  719.  
  720.                    The solution was simple and elegant: Whenever Opus reads
  721.                    a DLE (ASCII 16, or 10 hex, or ^P), it reads in one more
  722.                    byte, strips off its high bits and converts it into a
  723.                    control code. In other words, Opus treats the file it
  724.                    reads as a "cooked" one.
  725.  
  726.                    Avatar, level 0 (AVT/0 and AVT/0+), does not use cooked
  727.                    mode. There seemed to be no need for it at the time. The
  728.                    reason why AVT/0 was designed was to speed up screen
  729.                    control. Using DLE escaping seemed a waste of time. Opus
  730.                    1.10 (and later) treats oANSI files as cooked, but converts
  731.                    their contents into raw mode before sending them out.
  732.  
  733.                    Thus for example, if an oANSI file contains a DLE followed
  734.                    by the letter 'V', Opus 1.10 will send out a ^V. There is
  735.                    positively no mention of DLE escaping in any AVT/0
  736.                    documentation, as it is not used there.
  737.  
  738.                    Yet, it came to my attention that some programmers assumed
  739.                    DLE escaping should be used in AVT/0. This is a *wrong*
  740.                    assumption, not based on Avatar docs.
  741.  
  742. 26. Now, back to the present. Meanwhile it became obvious that DLE escaping
  743. might be useful. Because it does not use cooked mode, AVT/0 only works with an
  744. ideal data communications link, i.e. a link that modifies nothing.
  745. Unfortunately, that is not always the case.
  746.  
  747. 27. Let's examine some possible distortions:
  748.  
  749.                    The XON, XOFF protocol is a common way of dealing with
  750.                    buffer overrun. I do not want to go to any details about
  751.                    it here, because those who are familiar with the
  752.                    technicalities of this protocol would get bored, while
  753.                    those who are not either could not care less, or might
  754.                    need an explanation deeper than space permits.
  755.  
  756.                    At any rate, whenever this protocol is used, ^Q and ^S
  757.                    are sent out to stop and restart the flow. The two
  758.                    codes are eaten by the protocol and never get through.
  759.                    It so happens that Opus is not using this protocol when
  760.                    it is sending data to the caller's screen. But an
  761.                    inexperienced caller may have *his* terminal software
  762.                    configured for the XON, XOFF protocol. In that case any
  763.                    Avatar code that contains either ^Q or ^S will be
  764.                    distorted.
  765.  
  766.                    In AVT/0 chances of using ^Q and ^S are close to zero.
  767.                    The only place they could appear would be as a color
  768.                    attribute, but they do not represent a commonly used
  769.                    color.
  770.  
  771.                    In AVT/1, ^V ^Q is the query code, ^Q ^S is the sound code.
  772.                    The possibility of the XON, XOFF protocol getting in the
  773.                    way is stronger.
  774.  
  775.                    PC Pursuit of Telenet uses some control codes as its own
  776.                    escape code. Anyone who tried to upload a large file to
  777.                    a remote BBS over PC Pursuit using SEAlink got bitten by
  778.                    Telenet escape codes.
  779.  
  780.                    It is unlikely the Telenet escape codes of CR @ CR would
  781.                    happen in Avatar, but it is possible (e.g. in the
  782.                    parameters of the define window command).
  783.  
  784. 28. Other problems may occur locally, at terminal end:
  785.  
  786.                    MS DOS exapnds the TAB character into a number of blank
  787.                    spaces before it sends it to the console. TAB is the same
  788.                    as ^I which can be a color attribute. Moreover, ^V ^I is
  789.                    Avatar code to turn insert mode on. Thus, sending a ^I
  790.                    to the screen using standard MS DOS calls (which is
  791.                    what most programs running under MS DOS do) will result
  792.                    in something we did not want.
  793.  
  794.                    C language uses NUL as "end of string" marker. But NUL
  795.                    can be a window number in Avatar. A C program containing
  796.                    NUL in the middle of a string will not send the whole
  797.                    string, and it will never send the NUL.
  798.  
  799.                    A commonly used C function printf() expands a line feed
  800.                    to a carriage return followed by a line feed, at least it
  801.                    does it in the world of PC's.
  802.  
  803. 29. Because of all these possible problems, Avatar parser works, by default,
  804. in the cooked mode. That means when it reads a DLE, it waits for the next
  805. character. When the character comes, the parser strips the high bits and sends
  806. the result to the interpreter. Notice I said high bits, not high bit. So,
  807. if we call the character c, this is what it does:
  808.  
  809.                    c = c and 1F
  810.  
  811. Here, 1F is a hexadecimal number.
  812.  
  813. 30. Also note that Avatar parser does not pass the DLE to the intepreter. Of
  814. course, if there are two DLE's in a row, the second one will get through
  815. because DLE and DLE equals DLE.
  816.  
  817. 31. For compatibility with AVT/0, there is a code to turn Avatar parser to raw
  818. mode (see ^V = above). If you instruct Avatar parser to function in raw mode,
  819. it will not consider DLE an escape character, but will pass it onto the
  820. interpreter. The interpreter itself knows nothing about escaping. It
  821. interprets the codes exactly as they are defined. As you know, the interpreter
  822. is a separate part of Avatar console. It blindly interprets whatever codes
  823. get to it.
  824.  
  825. 32. Cooked mode is the default. That means when Avatar console first starts, it
  826. is in cooked mode. Whenever it is reset, it goes to cooked mode. As cooked
  827. and raw modes are functions of the parser, rather than interpreter, the same
  828. mode is always in all Avatar windows. The parser knows nothing about the
  829. windows, the interpreter does. But the interpreter knows nothing about raw
  830. and cooked modes, the parser does.
  831.  
  832. 33. Here is some sample code of this section of the parser. Here we assume a
  833. variable parsermode which can either equal RAW or COOKED:
  834.  
  835.         void parser (char c) {    /* c = character received */
  836.  
  837.                 static char lastchar = '\0';
  838.  
  839.                 if (parsermode == COOKED) {
  840.  
  841.                         if (lastchar == DLE) {
  842.                                 c &= 0x1f;
  843.                                 lastchar = '\0';
  844.                         }
  845.                         else if (c == DLE) {
  846.                                 lastchar = DLE;
  847.                                 return;         /* Note this !!! */
  848.                         }
  849.                 }
  850.  
  851.                 interpret(c);
  852.         }
  853.  
  854. 34. If you are not quite home in C, I'd like to tell you that a static
  855. variable keeps its value inbetween calls to this function. Its initial
  856. value is '\0' (NUL), but when it is changed to DLE, it remains DLE until
  857. it is explicitly changed.
  858.  
  859. 35. Now to the idea of the parser sending its output to the interpreter or
  860. somewhere else. While we think there is no need to use ANSI codes once
  861. Avatar has become established, we still have to deal with older software
  862. using ANSI sequences.
  863.  
  864. 36. Avatar console does not understand ANSI codes, with the only exception
  865. being <esc>[2J - clear the screen. Whenever Avatar console detects this
  866. sequence, it will clear current window.
  867.  
  868. 37. To accommodate software unsing ANSI codes, Avatar console is willing to
  869. send its interpreter to bed. The ^V FS code tells the interpreter to go to
  870. sleep. Whenever the parser sees the interpreter is asleep, it passes all
  871. output on to whatever console existed before Avatar.
  872.  
  873. 38. In practical life: If, on a PC, ANSI.SYS is loaded *before* AVATAR.SYS,
  874. ANSI will be in control when Avatar interpreter is asleep.
  875.  
  876. 39. You can awaken the interpreter by sending ^V GS to Avatar console. Note
  877. that Avatar is not responsible for another console to exist, let alone for it
  878. to be ANSI. But in real life, at least in PC world, there always exists a
  879. console. MS DOS creates a very primitive TTY console which still exists
  880. even if another console driver (even several drivers) is loaded.
  881.  
  882. 40. Outside of MS DOS world, creators of Avatar console drivers should make
  883. sure that there either is a default console or they should write one.
  884.  
  885.